<?php

session_start();
if($_SESSION['is_login'] !== 'yes'){
    header("Location:/login.php");
    exit;
}

define('YANGJIFANG',true);
require_once "db.php";
$db = new Db();

$sql = 'select * from posts order by id desc';
$rows = $db->getList($sql);

?>
<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>阳吉芳的博客</title>
</head>
<body>
<div>
    <a href="/admin.php">添加</a>
</div>
<?php foreach($rows as $row) {?>
    <li>
        <a href="/info.php?id=<?php echo $row['id']; ?> "><?php echo $row['title'];?></a>
        <span> <?php echo date('Y-m-d H:i:s',$row['add_time']);?></span>
        <a href="/update.php?id=<?php echo $row['id'];?> " target="_blank">修改</a>
        <a href="/delete.php?id=<?php echo $row['id'];?> " target="_blank">删除</a>
    </li>
<?php } ?>
</body>
</html>

